<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>{$title}</legend>
    </fieldset>
    <form class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label class="layui-form-label">父级名称</label>
            <div class="layui-input-4">
                <select name="pid" lay-filter="pid">
                    <option value="0" {if $info == 'null' || $info['pid']==0} selected{/if}>一级分类</option>
                    {volist name="p_list" id="vv"}
                    <option value="{$vv['id']}" {if @$info['pid'] == $vv['id']} selected{/if} {if @$info['id'] == $vv['id']} disabled{/if}>{$vv['title']}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分类名称</label>
            <div class="layui-input-4">
                <input type="text" name="title" value="{$info.title|default=''}" lay-verify="required" placeholder="{:lang('pleaseEnter')}分类名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否开启</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" {if $info == 'null' || $info['status']==1} checked {/if}title="{:lang('open')}">
                <input type="radio" name="status" value="0" {if $info != 'null' && $info['status']==0} checked {/if}title="{:lang('close')}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('order')}</label>
            <div class="layui-input-4">
                <input type="text" name="sort" value="{$info.sort|default=''}" placeholder="从小到大排序" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
                <a href="{:url('cat_list')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form, $ = layui.jquery;
        form.on('submit(submit)', function (data) {
            // 提交到方法 默认为本身
            var loading = layer.load(1, {shade: [0.1, '#fff']});
            data.field.id = '{$info.id|default=0}';
            $.post("", data.field, function (res) {
                layer.close(loading);
                if (res.code > 0) {
                    layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                        location.href = res.url;
                    });
                } else {
                    layer.msg(res.msg, {time: 1800, icon: 2});
                }
            });
        })
    });
</script>